package mq

import (
	"sync"

	"github.com/nsqio/go-nsq"
)

var (
	once     sync.Once
	producer *nsq.Producer
)

func New(nsqAddr string, config *nsq.Config) *nsq.Producer {
	once.Do(func() {
		var err error
		producer, err = nsq.NewProducer(nsqAddr, config)
		if err != nil {
			panic("初始化nsq错误")
		}
	})
	return producer
}
